test for babl_class_name
authorØyvind Kolås <ok@src.gnome.org>
Tue, 23 Aug 2005 07:39:59 +0000 (07:39 +0000)
committerØyvind Kolås <ok@src.gnome.org>
Tue, 23 Aug 2005 07:39:59 +0000 (07:39 +0000)
tests/Makefile.am
tests/babl_class_name.c [new file with mode: 0644]

index e39b1fdaaf0ef287389265a61d2ea18fb6434448..1bc9955d9c39855a40096b1bf378da7afe604b04 100644 (file)
@@ -4,7 +4,8 @@ TESTS =                         \
        u8_to_float             \
        rgb_to_lab_to_rgb       \
        rgb_to_ycbcr            \
-       rgb_to_ycbcr_to_rgb
+       rgb_to_ycbcr_to_rgb     \
+       babl_class_name
 
 float_to_u8_SOURCES         = float_to_u8.c
 u8_to_float_SOURCES         = u8_to_float.c
@@ -12,6 +13,7 @@ grayscale_to_rgb_SOURCES    = grayscale_to_rgb.c
 rgb_to_lab_to_rgb_SOURCES   = rgb_to_lab_to_rgb.c
 rgb_to_ycbcr_SOURCES        = rgb_to_ycbcr.c
 rgb_to_ycbcr_to_rgb_SOURCES = rgb_to_ycbcr_to_rgb.c
+babl_class_name_SOURCES     = babl_class_name.c
 
 
 AM_CFLAGS = -I$(top_srcdir) -I$(top_srcdir)/babl
@@ -28,6 +30,4 @@ introspect_SOURCES     = introspect.c
 babl_html_dump_SOURCES = babl-html-dump.c
 nop_SOURCES            = nop.c
 
-
 EXTRA_DIST = .cvsignore
-
diff --git a/tests/babl_class_name.c b/tests/babl_class_name.c
new file mode 100644 (file)
index 0000000..643848b
--- /dev/null
@@ -0,0 +1,75 @@
+/* babl - dynamically extendable universal pixel conversion library.
+ * Copyright (C) 2005, Øyvind Kolås.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+#include <string.h>
+#include <stdio.h>
+#include "babl.h"
+
+struct
+  {
+    long  klass;                          const char *name;
+                       } reference[]= {
+    {BABL_INSTANCE,                       "BablInstance"},
+    {BABL_TYPE,                           "BablType"},
+    {BABL_TYPE_INTEGER,                   "BablTypeInteger"},
+    {BABL_TYPE_FLOAT,                     "BablTypeFloat"},
+    {BABL_SAMPLING,                       "BablSampling"},
+    {BABL_COMPONENT,                      "BablComponent"},
+    {BABL_MODEL,                          "BablModel"},
+    {BABL_PIXEL_FORMAT,                   "BablPixelFormat"},
+    {BABL_CONVERSION,                     "BablConversion"},
+    {BABL_CONVERSION_TYPE,                "BablConversionType"},
+    {BABL_CONVERSION_TYPE_PLANAR,         "BablConversionTypePlanar"},
+    {BABL_CONVERSION_MODEL_PLANAR,        "BablConversionModelPlanar"},
+    {BABL_CONVERSION_PIXEL_FORMAT,        "BablConversionPixelFormat"},
+    {BABL_CONVERSION_PIXEL_FORMAT_PLANAR, "BablConversionPixelFormatPlanar"},
+    {BABL_FISH,                           "BablFish"},
+    {BABL_FISH_REFERENCE,                 "BablFishReference"},
+    {BABL_IMAGE,                          "BablImage"},
+    {BABL_SKY,                            "BablSky"},
+    {0, NULL}
+  };
+
+int
+test (void)
+{
+  int i=0;
+  int OK=1;
+  while (reference[i].klass)
+    {
+      if (strcmp (reference[i].name, babl_class_name (reference[i].klass)))
+        {
+          OK=0;
+          printf ("'%s'!='%s'\n", reference[i].name, babl_class_name (reference[i].klass));
+        }
+      i++;
+    }
+  return !OK;
+}
+
+int
+main (int    argc,
+      char **argv)
+{
+  babl_init ();
+  if (test())
+    return -1;
+  babl_destroy ();
+  return 0;
+}